package com.example.administrator.szb.http;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.example.administrator.szb.bean.Messages;


/**fastjson alibaba的json解析库
 * Created by syh on 2016/7/1.
 */
public class JsonUtils {
    private static final String TAG = "JsonUtils";


    public static String JsonParse(Messages messages){
        if (messages.getData() instanceof String){
            return (String)messages.getData();
        }else{
            return JSON.toJSONString(messages.getData());
        }


    }
    /**
     * result : 0
     * err_code : 1
     * err_msg : 手机号码格式不正确！
     * data : {}
     */
    public static Messages getMessages(byte[] bytes){
        String str = new String(bytes);
        Messages messages = JSON.parseObject(str,new TypeReference<Messages>(){});
        return messages;
    }
    public static Messages getMessages2(String str){
        Messages messages = JSON.parseObject(str,new TypeReference<Messages>(){});
        return messages;
    }
}
